package designpatterns.proxy.demo02;

/**
 * @author 真香
 * @create 2021-05-31 23:05
 */
public class UserServiceProxy implements UserService {

    private UserServiceImpl userService;

    // Spring 推荐使用set方法注入
    public void setUserService(UserServiceImpl userService) {
        this.userService = userService;
    }

    @Override
    public void add() {

        printLog("add");
        userService.add();

    }

    @Override
    public void delete() {
        printLog("delete");
        userService.delete();
    }

    @Override
    public void update() {
        printLog("update");
        userService.update();

    }

    @Override
    public void select() {
        printLog("select");
        userService.select();
    }


    public void printLog(String msg){

        System.out.println("proxy 使用了"+msg+"方法");
    }
}
